package com.cqggrw.action;

import com.cqggrw.domain.Appraise;
import com.cqggrw.domain.Json;
import com.cqggrw.service.AppraiseServiceI;
import com.cqggrw.service.impl.AppraiseServiceImpl;
import com.opensymphony.xwork2.ModelDriven;

public class AppraiseAction extends BaseAction implements ModelDriven<Appraise> {
	
	private static final long serialVersionUID = 1L;
	private AppraiseServiceI service = new AppraiseServiceImpl();
	public Appraise t = new Appraise();
	
	public void add() {
		Json json = new Json();
		if (service.addAppraise(t)) {
			json.setSuccess(true);
			json.setMsg("评论成功!");
		} else {
			json.setSuccess(false);
			json.setMsg("评论失败!");
		}

		super.writeJson(json);
	}
	
	public void delete() {
		Json json = new Json();
		if (service.delete(t.getId())) {
			json.setSuccess(true);
			json.setMsg("删除成功!");
		} else {
			json.setSuccess(false);
			json.setMsg("删除失败!");
		}
		
		super.writeJson(json);
	}
	
	public void get() {
		super.writeJson(service.getList(t));
	}
	
	public void getById() {
		super.writeJson(service.getById(t.getId()));
	}

	public Appraise getModel() {
		return t;
	}

}
